# -*- coding: utf-8 -*-
# @Time    : 2022/10/10 23:46
# @Author  : 修远
# @File    : customjsonencoder.py
# @Comment : 
from datetime import datetime, date
from flask.json import JSONEncoder as _JSONEncoder


class CustomJSONEncoder(_JSONEncoder):
    def default(self, obj):
        if isinstance(obj, datetime):
            return obj.strftime('%Y-%m-%d %H:%M:%S')
        elif isinstance(obj, date):
            return obj.strftime('%Y-%m-%d')
        else:
            return _JSONEncoder.default(self, obj)
